import cookies from 'react-cookies'
import {
    axiosConfig,
    success,
    error
} from './config';

export const getToken = (): string => {
    const token: string = cookies.load('Authorization')
    return token;
}

// 普通的前端应答方式
export const commonReply = (res: axiosConfig) => {
    if (res.code === 0) {
        success(res.message)
    } else {
        error(res.message)
    }
}

export const handleCourse = (course: number): string => {
    const contrast = {
        1: '第一二节课',
        2: '第三四节课',
        3: '第四五节课',
        4: '第七八节课'
    }
    return contrast[course]
}

export const handleTimeStamp = (timestamp: string): string => {
    const tempDate = new Date(parseInt(timestamp));
    const year = tempDate.getFullYear();
    const month = tempDate.getMonth() + 1;
    const day = tempDate.getDate();
    return `${year}-${month}-${day}`
}